import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
// 引入 HeroesComponent 准备跳转
import { HeroesComponent }   from './heroes/heroes.component';
// 引入 DashboardComponent
import { DashboardComponent }   from './dashboard/dashboard.component';
// 引入 HeroDetailComponent
import { HeroDetailComponent }  from './hero-detail/hero-detail.component';

const routes: Routes = [
  { path: 'heroes', component: HeroesComponent },
  { path: 'dashboard', component: DashboardComponent },
  { path: 'detail/:id', component: HeroDetailComponent },
  { path: '', redirectTo: '/dashboard', pathMatch: 'full' } //router-outlet 整体（full）是空白的话，就把 dashboard 那个请求弄过去
];

@NgModule({
  imports: [RouterModule.forRoot(routes)], // 自动就有的 提供路由所需的服务提供商和指令，还会基于浏览器的当前 URL 执行首次导航
  exports: [RouterModule]
})
export class AppRoutingModule { }
